package com.tdam2011.grupo05.control.adapters;

import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.View;
import android.widget.ImageView;
import android.widget.QuickContactBadge;

import com.tdam2011.grupo05.R;

public class ContactPhoneAdapter extends SimpleCursorAdapter {

	ImageView mMoreIv = null;

	public ContactPhoneAdapter(Context context, int layout, Cursor c,
			String[] from, int[] to, int flag) {
		super(context, layout, c, from, to, flag);

	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {

		int id = cursor.getColumnIndex(ContactsContract.Contacts._ID);
		Uri uri = ContentUris.withAppendedId(
				ContactsContract.Contacts.CONTENT_URI, cursor.getLong(id));
		
		// falta resolver la imagen del contacto!
		QuickContactBadge quickContactBadge = (QuickContactBadge) view
				.findViewById(R.id.contacto_imagen_badge);
		quickContactBadge.assignContactUri(uri);
		quickContactBadge.setMode(ContactsContract.QuickContact.MODE_SMALL);

		super.bindView(view, context, cursor);
	}

	// @Override
	// public View getView(int position, View convertView, ViewGroup parent) {
	// View view;
	// Cursor cursor = (Cursor) getItem(position);
	//
	// if (convertView == null) {
	// view = mInflater
	// .inflate(R.layout.list_item_contacto, parent, false);
	// } else {
	// view = convertView;
	// }
	//
	// ((TextView) view.findViewById(R.id.nombre_contacto))
	// .setText(cursor.getString(cursor
	// .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)));
	// return view;
	// }
}
